package com.jiuling.apis.service.basic;

import com.jiuling.apis.model.Hmodel.TMenu;
import com.jiuling.apis.model.Pmodel.Parea;
import com.jiuling.apis.model.Pmodel.Pmenu;
import com.jiuling.apis.model.Pmodel.User;
import com.jswzc.dao.hdao.BaseDaoI;
import com.jswzc.dao.mdao.DaoSupport;
import com.jswzc.framework.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;


/**
 * Created by yzljj on 2016/6/23.
 */
@Service("homeService")
public class HomeServiceImpl implements  HomeServiceI {

    private SimpleDateFormat shortSdf;
    @Autowired
    private BaseDaoI<TMenu> menuDao;

    @Resource(name = "daoSupport")
    private DaoSupport dao;

    @Autowired
    private BaseDaoI baseDao;


    @SuppressWarnings("unchecked")
    @Override
    public List<Pmenu> showLeftMenu() throws Exception {
        List<Pmenu> pmenuList = null;
        pmenuList = (List<Pmenu>) dao.findForList("homeDao.findAllMenu", null);
        return pmenuList;
    }

    @Override
    public List<Parea> getList(String deep) throws Exception {
        return (List<Parea>)dao.findForList("homeDao.getList", deep);
    }

    @Override
    public List<Parea> getList(String lev, String id) throws Exception {
        Map<String, Object> paramsMap=new HashMap<String, Object>();
        paramsMap.put("deep",lev);
        paramsMap.put("id",id);
        List<Parea> pareaList=(List<Parea>)dao.findForList("homeDao.getListParm", paramsMap);
        return pareaList;
    }

    @Override
    public List<Parea> getListByPid(String lev, String pid) throws Exception {
        Map<String, Object> paramsMap=new HashMap<String, Object>();
        paramsMap.put("deep",lev);
        paramsMap.put("pid",pid);
        List<Parea> pareaList=(List<Parea>)dao.findForList("homeDao.getListParmByPid", paramsMap);
        return pareaList;
    }

    @Override
    public List<Pmenu> showLeftMenuByRole(short identity) throws Exception {
        List<Pmenu> pmenuList = null;
        pmenuList = (List<Pmenu>) dao.findForList("homeDao.showLeftMenuByRole", identity);
        return pmenuList;
    }
}